//==================================================================================
//		Dual Quad Board Program
//		file name : Global_Variable.H
//		version : 1.0
//		target device : w78e516(winbond)
//		target board : dual quad board
//		c compiler : Keil
//==================================================================================

U8 bdata	global_flag_status = 0x48;


//U16 tt;

U8 idata loss_channel_info_backup = 0;	
//U16 loss_channel_info_change = 0;		

//U8 idata loss_first_time = 0;


U8 idata count[8]={0,0,0,0,0,0,0,0};

//... NTSC : 1 ,  PAL : 0
sbit	b_video_fmt = global_flag_status^7;
//... ON :  Page A ,  OFF : Page B 				
sbit	display_page = global_flag_status^6;
//... ON :  Freeze Option ON ,  OFF : Freeze Option OFF				
sbit	freeze_option = global_flag_status^5;
//... ON :  Display,  OFF : Erase 				
sbit	title_display = global_flag_status^4;	
//... ON :  Display,  OFF : Erase 				
sbit	date_display = global_flag_status^3;	
//... ON :  Display,  OFF : Erase
sbit	language = global_flag_status^2;
//... ON :  ,  OFF : 								//... 00: Y-M-D   01: M-D-Y   10: D-M-Y
sbit	date_format1 = global_flag_status^1;	
//... ON :  ,  OFF : 
sbit	date_format2 = global_flag_status^0;
//---------------------------------------------

//---------------------------------------------
U8 bdata	key_flag_status = 0x00;

//... ON : Long Key ,  OFF : Short Key
sbit	long_key_in = key_flag_status^7;
//... ON : key in ,  OFF : key off
sbit	key_in = key_flag_status^6;
//... ON : Event ON ,  OFF : Event OFF 
sbit	alarm_on = key_flag_status^5;
//... ON : VCR Zoom On ,  OFF : VCR Zoom Off
sbit	vcr_zoom_on = key_flag_status^4;
//... ON : Change ON ,  OFF : Change OFF
sbit	ch_control_on_off = key_flag_status^3;
//... ON : Page Change ON ,  OFF : Page Change OFF
sbit	multi_function_in = key_flag_status^2;
//... ON : Event ON ,  OFF : Event OFF
sbit	event_on = key_flag_status^1;
//... ON : V Sync in ,  OFF : V Sync off
sbit	v_sync_in = key_flag_status^0;
//---------------------------------------------


//---------------------------------------------
U8 bdata	menu_flag_status = 0x00;

//... ON : Menu On ,  OFF : Menu Off
sbit	menu_on = menu_flag_status^7;
//... ON : Menu On ,  OFF : Menu Off
sbit	sub_menu_on = menu_flag_status^6;
//... ON : Zoom Mode On ,  OFF : Zoom Mode Off
sbit	zoom_mode_in = menu_flag_status^5;
//... ON : Zoom On ,  OFF : Zoom Off
sbit	zoom_mode_on  = menu_flag_status^4;
//... ON : VCR Mode In ,  OFF : VCR Mode Out
sbit	vcr_mode_in  = menu_flag_status^3;
//... ON : freeze Mode In ,  OFF : freeze Mode Out
sbit	freeze_on  = menu_flag_status^2;
//... ON : Auto Sequence Mode In ,  OFF : Auto Sequence Mode Out
sbit	auto_sequence_on  = menu_flag_status^1;
//... ON :    ,  OFF : 			
sbit	auto_mode_flag = menu_flag_status^0;
//---------------------------------------------

//---------------------------------------------
U8 bdata	remote_data_flag_status = 0x00;

//... ON :  Strobe  ,  OFF : Strobe			
sbit	strobe_update_path_on = remote_data_flag_status^7;
//... ON :  Strobe  ,  OFF : Strobe			
sbit	strobe_rec_path_on = remote_data_flag_status^6;
//... ON :  Strobe  ,  OFF : Strobe			
sbit	strobe_loss_check_on = remote_data_flag_status^5;
//... ON :  Strobe  ,  OFF : Strobe			
sbit	strobe_enable_on = remote_data_flag_status^4;
//... ON :  Remote Long Key ON ,  OFF : Remote Long Key OFF			
sbit	remote_long_key_on = remote_data_flag_status^3;
//... ON :  Remote Data ON ,  OFF : Remote Data OFF			
sbit	remote_int_on = remote_data_flag_status^2;
//... ON :  Remote Data ON ,  OFF : Remote Data OFF			
sbit	remote_data_on = remote_data_flag_status^1;
//... ON : Start Code Yes ,  OFF : Start Code Fail
sbit	remote_start_flag  = remote_data_flag_status^0;
//---------------------------------------------

U8 bdata	etc_flag_status = 0x80;

//... ON : Sound ON ,  OFF : SOUND OFF
sbit	key_sound = etc_flag_status^7;
//... ON : Auto Moving ON ,  OFF : Auto Moving OFF
sbit	splite_2_auto_stop = etc_flag_status^6;
//... ON : Auto Moving ON ,  OFF : Auto Moving OFF
sbit	splite_2_auto_flag_R = etc_flag_status^5;
//... ON : Auto Moving ON ,  OFF : Auto Moving OFF
sbit	splite_2_auto_flag_L = etc_flag_status^4;
//... ON : Auto Moving ON ,  OFF : Auto Moving OFF
sbit	splite_2_auto_move = etc_flag_status^3;
//... ON : Splite 2 Channel Size Control ON ,  OFF : Splite 2 Channel Size Control OFF
sbit	splite_2_flag = etc_flag_status^2;
//... ON : A/B Page Switching ,  OFF : Event Only A or B Page
sbit	event_display_a_b = etc_flag_status^1;

//---------------------------------------------

U8 bdata	option_flag_status = 0x00;
sbit	first_skip = option_flag_status^4;
sbit	serial_tx_pass= option_flag_status^3;
sbit	serial_tx_flag_start = option_flag_status^2;
sbit	auto_seq_option = option_flag_status^1;
sbit	serial_tx_flag = option_flag_status^0;
//---------------------------------------------

U8 data key_off_count = 0x00;			//... key off count
U8 data key_on_count = 0x00;			//... key on count
U8 data long_key_timer = 0x00;		//... Long Key or Short Key Check
U8 data key_code = 0x00;				//... key kinds
U8 data key_value_backup = 0x00;
U8 data key_value_backup1 = 0x00;
//U8 idata led_on_off_data = 0x00;
U8 data g_sys_version;

U8 data v_sync_count = 0x00;			//... Counter
U8 idata motion_skip_count = 0x00;		//... Counter
U8 idata one_sec = 0x00;				//... 1 Sec counter
U8 idata event_one_sec = 0x00;		//... 1 Sec counter
U8 idata buzzer_sound = 0x00;	

U8 idata event_bitmap_counter = 0x00;	

U8 idata channel_path_Check = 0;		

U8 data main_menu_select_bar = 0x01;
S16 data sub_menu_select_bar = 0x01;
S16 data sub_menu_select_bar_backup = 0x01;	

U8 idata display_mode = 0x01;
//U8 idata auto_display_mode = 0x01;
U8 idata display_mode_backup = 0x01;
U8 idata display_mode_change = 0x00;

S8 idata camera_number = 0x00;	
U8 idata edit_cursor = 0x00;

U8 idata	event_quad_display_flag = 0x00;

U8 idata rtc_backup = 0;
S8 idata hh_backup = -1;		
S8 idata mm_backup = -1;		
S8 idata y_backup = -1;		
S8 idata m_backup = -1;		
S8 idata d_backup = -1;		

U8 idata led_on_off_flag=0;

U8 idata channel_select_cursor = 0;

U8 idata alarm_channel_info = 0;
U8 idata alarm_channel_info_old = 0;
U8 idata list_alarm_channel_info = 0;
U8 idata osd_alarm_channel_info = 0;

U8 idata loss_channel_info = 0;			
U8 idata loss_channel_info_old = 0;		
U8 idata list_loss_channel_info = 0;		

U8 idata motion_channel_info = 0;
U8 idata motion_channel_info_old = 0;
U8 idata list_motion_channel_info = 0;
U8 idata osd_motion_channel_info = 0;

S8 idata event_list_read_address = 0x00;	
S8 idata event_list_page = 0x00;

U8 idata motion_enable_flag = 0; 

U8 idata event_list_buff[8];

S8 idata zoom_x_loc = 0x00;
S8 idata zoom_y_loc = 0x00;

S8 idata pip_full_ch = 0x00;
S8 idata pip_sub_ch_1 = 0x01;
S8 idata pip_sub_ch_2 = 0x02;
S8 idata pip_sub_ch_3 = 0x03;
	


U8 idata	motion_write_flag = 0xff;	
U8 idata loss_write_flag = 0xff; 
U8 idata	 alarm_write_flag = 0xff; 	

//U16 idata win_scrn_8ch_strb_delay = 0;


U8 idata remote_data[4] = {0,0,0,0};
U8 idata remote_data_old[4] ={0,0,0,0};
U16 idata remote_long_key_counter = 0;
U8 idata remote_data_write_counter = 0;
U8 idata remote_counter = 0;
U16 idata remote_long_counter = 0;
///*  Not used for tw2835 (070914)
//U8 idata	serial_tdata[6] = 0x00;
U8 idata	serial_rdata = 0x00;
//U8 idata serial_counter_rx = 0;
//U8 idata serial_counter_tx = 0;

//#define EXTERNal_ALARM

//VGA
U8 vga_mode=1;
//==================================================================================
U8	idata cmn_bot ;
U8	idata cmn_cnt_vs=0;
U8	idata cmn_cnt_vs_sub=0;
//
/*U8 bdata	wndw_flg_ds = 0x10;//BIT4;//0x00;
sbit	b_ds_pb_cif = wndw_flg_ds^7;
sbit	b_ds_wth_4pb = wndw_flg_ds^6;
sbit	b_ds_wth_16pb = wndw_flg_ds^5;
sbit	b_ds_wth_rc = wndw_flg_ds^4;						//... default=1
//sbit	b_ds_in_eror = wndw_flg_ds^5;
sbit	b_ds_in_run = wndw_flg_ds^3;
sbit	b_ds_in_auto = wndw_flg_ds^2;*/
